#include <iostream>
#include <string>
#include <thread>
#include <mutex>
#include <unistd.h>
#include <ostream>
#include <math.h>
#include <pcl/io/pcd_io.h> // PCL的pcd格式文件的输入输出头文件
#include <pcl/point_types.h> //PCL对各种格式的点的支持头文件
#include <pcl/visualization/pcl_visualizer.h> //点云查看窗口头文件
#include <pcl/io/ply_io.h>
#include <pcl/io/hdl_grabber.h>
#include <pcl/filters/passthrough.h>

#define PCD_FOLDER "/home/zty/Faw_Project/src/pcl_utils/pcd_files/"
#define PCD_PREFIX "AreaPick"
#define PCD_SUBFIX ".pcd"
#define PCD_HEAD "# .PCD v0.7 - Point Cloud Data file format\nVERSION 0.7\nFIELDS x y z intensity\nSIZE 4 4 4 4\nTYPE F F F F\nCOUNT 1 1 1 1\nWIDTH "
#define PCD_MID "\nHEIGHT 1\nVIEWPOINT 0 0 0 1 0 0 0\nPOINTS "
#define PCD_RAIL "\nDATA ascii"

using namespace std;
using namespace pcl;
using namespace io;
typedef pcl::PointXYZI PointCloudType;
typedef pcl::PointCloud<PointCloudType> Cloud;
typedef Cloud::ConstPtr CloudConstPtr;
class PCL_UTILS{
        public:
                bool read_pcd_file(const char * filename);
                void display_pcd_files(const char * filename, bool area_picking);
                boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
                void write_pcd(pcl::PointCloud<PointCloudType>::Ptr pcd_cloud);
                void bbox2pcd_file(PointCloud<PointCloudType>::Ptr point_cloud, float x, float y, float z, float length, float width, float height, float angle);
                bool filter_pc(float min_x, float max_x, float min_y, float max_y, float min_z, float max_z);

                PCL_UTILS();
                ~PCL_UTILS();
        private:
                PointCloud<PointCloudType>::Ptr pc;
                void AreaPicking_callback(const pcl::visualization::AreaPickingEvent& event, void* args);
                pcl::PointCloud<PointCloudType>::Ptr clicked_points_3d;
                int pcd_file_num; //框选的pcd文件的序号
                int num; //计数cloudname
};